package com.skt.common_hr.resupport.model
{
	import com.skt.common_hr.common.Variables;
	import com.skt.common_hr.common.puremvc.CommonProxy;
	import com.skt.common_hr.resupport.ResupportFacade;
	
	import mx.collections.ArrayCollection;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;

	public class ResupportSubjectCodeProxy extends CommonProxy
	{
		public static const NAME:String = "medicalSubjectCodeProxy";

		
		// 구분 
		public var acMedSubject2:ArrayCollection;

		public function ResupportSubjectCodeProxy(data:Object=null)
		{
			super(NAME, data);
		}


		// 진료과목 콤보박스 내용
		public function loadMedSubjectCodes():void
		{
			var param:Object = new Object();
			param["I_COGBN"] = Variables.myPernr;
			param["I_GJAHR"] = '2012';

			loadData("Z_HR_RE01", param, corsnResult2, corsnFault);
		}

		public function corsnResult2(event:ResultEvent):void
		{
			if(retCode==0) {
				acMedSubject2 = parseCorsn2(event.result.OTAB);
				facade.sendNotification(ResupportFacade.LOAD_MEDICALMONEY_MEDSUBJECT_COMPLETE, this);
			}
			else {
				facade.sendNotification(ResupportFacade.LOAD_MEDICALMONEY_MEDSUBJECT_FAILED, this);
			}
		}
		
		private function corsnFault(event:FaultEvent):void
		{
			facade.sendNotification(ResupportFacade.LOAD_MEDICALMONEY_MEDSUBJECT_FAILED, this);
		}
		
		
		private function parseCorsn2(srcArr:ArrayCollection):ArrayCollection
		{
			var retArr:ArrayCollection = new ArrayCollection();
			
			retArr.addItem({label:'구분선택', data:-1});
			for each(var rec:Object in srcArr)
			{
				retArr.addItem({label:rec["TEXT"], data:rec["CODE"]});
			}
			return retArr;
		}		

	}
}